package com.example.springboot.service;

import com.example.springboot.entity.Yard;
import com.example.springboot.entity.YardExample;
import com.example.springboot.mapper.YardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: jyf2000jyf
 * @Date: 2022/5/24
 * @Time: 22:09
 * @Email: 904593011@qq.com
 * @Description:
 **/
@Service
public class YardServiceImpl implements YardService {
    @Autowired
    YardMapper yardMapper;

    @Override
    public List<Object> initYard(Integer yard) {
        YardExample example = new YardExample();
        example.createCriteria().andRegionEqualTo(yard);
        List<Yard> yards = yardMapper.selectByExample(example);
        List<Object> list = new ArrayList<>();
        for (Yard singleYard : yards) {
            List<Integer> everyPosition = new ArrayList<>();
            everyPosition.add(singleYard.getColumn()-1);
            everyPosition.add(singleYard.getRow()-1);
            everyPosition.add(singleYard.getHeight());
            list.add(everyPosition);
        }
        return list;
    }

    @Override
    public List<Object> initYards() {
        return null;
    }
}
